{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import QUANTAXIS as QA\n",
    "import pandas as pd\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## QUANTAXIS 的一般/高级财务方法\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.QA.QA_fetch_financial_report(code,report_date)\n",
    "\n",
    "其中, report_date 是需要手动指定的财务时间, 可以是单个时间,也可以是一列时间:\n",
    "  > '2018-03-31'  或者['2017-03-31','2017-06-30','2017-09-31','2017-12-31','2018-03-31']\n",
    "  > 此方法的意义在于指定特定的财务时间(如年报)\n",
    "  \n",
    "返回的是一个MultiIndex的dataframe\n",
    " \n",
    "2.QA.QA_fetch_financial_report_adv(code,start,end)\n",
    "\n",
    "支持随意的跨时间索引, start 和end不用刻意指定\n",
    "\n",
    "如果end不写,则start参数等同于report_date的用法\n",
    "\n",
    "返回的是QA_DataStruct_Financial 类\n",
    "\n",
    "3. QA_DataStruct_Financial 类, 可以直接加载在基础方法返回的dataframe中\n",
    "\n",
    "> QDF.get_report_by_date(code,date) 返回某个股票的某个时间点的财报\n",
    "\n",
    "> QDF.get_key(code,date,key) 返回某个股票某个时间点的财报的某个指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "res=QA.QA_fetch_financial_report(['000001','600100'],['2017-03-31','2017-06-30','2017-09-31','2017-12-31','2018-03-31'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>EPS</th>\n",
       "      <th>deductEPS</th>\n",
       "      <th>undistributedProfitPerShare</th>\n",
       "      <th>netAssetsPerShare</th>\n",
       "      <th>capitalReservePerShare</th>\n",
       "      <th>ROE</th>\n",
       "      <th>operatingCashFlowPerShare</th>\n",
       "      <th>moneyFunds</th>\n",
       "      <th>tradingFinancialAssets</th>\n",
       "      <th>billsReceivables</th>\n",
       "      <th>...</th>\n",
       "      <th>netProfitLastYear</th>\n",
       "      <th>277</th>\n",
       "      <th>278</th>\n",
       "      <th>279</th>\n",
       "      <th>280</th>\n",
       "      <th>281</th>\n",
       "      <th>282</th>\n",
       "      <th>_id</th>\n",
       "      <th>code</th>\n",
       "      <th>report_date</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>report_date</th>\n",
       "      <th>code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-03-31</th>\n",
       "      <th>000001</th>\n",
       "      <td>0.3100</td>\n",
       "      <td>0.3100</td>\n",
       "      <td>4.05</td>\n",
       "      <td>10.9400</td>\n",
       "      <td>3.29</td>\n",
       "      <td>2.992</td>\n",
       "      <td>-6.700</td>\n",
       "      <td>7.121477e+11</td>\n",
       "      <td>4.404400e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.272700e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>6.955837e+08</td>\n",
       "      <td>2.89</td>\n",
       "      <td>0.3617</td>\n",
       "      <td>5b3edccc50d2c15048795415</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-06-30</th>\n",
       "      <th>000001</th>\n",
       "      <td>0.6800</td>\n",
       "      <td>0.6800</td>\n",
       "      <td>4.26</td>\n",
       "      <td>11.1500</td>\n",
       "      <td>3.29</td>\n",
       "      <td>6.100</td>\n",
       "      <td>-7.470</td>\n",
       "      <td>7.522773e+11</td>\n",
       "      <td>4.908300e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.286100e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.684470e+08</td>\n",
       "      <td>6.21</td>\n",
       "      <td>0.3670</td>\n",
       "      <td>5b3edcce50d2c15048796114</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-06-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31</th>\n",
       "      <th>000001</th>\n",
       "      <td>1.3000</td>\n",
       "      <td>1.3000</td>\n",
       "      <td>4.64</td>\n",
       "      <td>11.7706</td>\n",
       "      <td>3.29</td>\n",
       "      <td>11.474</td>\n",
       "      <td>-6.920</td>\n",
       "      <td>7.506320e+11</td>\n",
       "      <td>3.957500e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.318900e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.071157e+09</td>\n",
       "      <td>11.62</td>\n",
       "      <td>0.2348</td>\n",
       "      <td>5b3edcd150d2c15048797c47</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-12-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-03-31</th>\n",
       "      <th>000001</th>\n",
       "      <td>0.3300</td>\n",
       "      <td>0.3300</td>\n",
       "      <td>4.69</td>\n",
       "      <td>11.8500</td>\n",
       "      <td>3.29</td>\n",
       "      <td>3.242</td>\n",
       "      <td>2.410</td>\n",
       "      <td>6.699981e+11</td>\n",
       "      <td>7.684500e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.357000e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>9.828775e+08</td>\n",
       "      <td>2.79</td>\n",
       "      <td>0.3818</td>\n",
       "      <td>5b3edcd250d2c15048798a07</td>\n",
       "      <td>000001</td>\n",
       "      <td>2018-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-03-31</th>\n",
       "      <th>600100</th>\n",
       "      <td>-0.0908</td>\n",
       "      <td>-0.1030</td>\n",
       "      <td>2.57</td>\n",
       "      <td>7.1879</td>\n",
       "      <td>3.15</td>\n",
       "      <td>-1.263</td>\n",
       "      <td>-0.885</td>\n",
       "      <td>7.738101e+09</td>\n",
       "      <td>9.173491e+08</td>\n",
       "      <td>90043088.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.169131e+09</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.155126e+07</td>\n",
       "      <td>-1.25</td>\n",
       "      <td>-0.1030</td>\n",
       "      <td>5b3edccc50d2c15048795c3a</td>\n",
       "      <td>600100</td>\n",
       "      <td>2017-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-06-30</th>\n",
       "      <th>600100</th>\n",
       "      <td>-0.0407</td>\n",
       "      <td>-0.0598</td>\n",
       "      <td>2.37</td>\n",
       "      <td>6.9775</td>\n",
       "      <td>3.15</td>\n",
       "      <td>-0.584</td>\n",
       "      <td>-1.124</td>\n",
       "      <td>8.756578e+09</td>\n",
       "      <td>7.745308e+08</td>\n",
       "      <td>52524456.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-7.752181e+08</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.842445e+07</td>\n",
       "      <td>-0.56</td>\n",
       "      <td>0.0432</td>\n",
       "      <td>5b3edcce50d2c15048796987</td>\n",
       "      <td>600100</td>\n",
       "      <td>2017-06-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31</th>\n",
       "      <th>600100</th>\n",
       "      <td>0.0350</td>\n",
       "      <td>-0.0115</td>\n",
       "      <td>2.45</td>\n",
       "      <td>7.1765</td>\n",
       "      <td>3.10</td>\n",
       "      <td>0.487</td>\n",
       "      <td>0.153</td>\n",
       "      <td>9.766134e+09</td>\n",
       "      <td>5.818680e+08</td>\n",
       "      <td>117617800.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1.036393e+08</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4.0</td>\n",
       "      <td>5.628596e+07</td>\n",
       "      <td>0.48</td>\n",
       "      <td>0.0791</td>\n",
       "      <td>5b3edcd150d2c150487984ca</td>\n",
       "      <td>600100</td>\n",
       "      <td>2017-12-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-03-31</th>\n",
       "      <th>600100</th>\n",
       "      <td>-0.0756</td>\n",
       "      <td>-0.0871</td>\n",
       "      <td>2.37</td>\n",
       "      <td>7.1433</td>\n",
       "      <td>3.20</td>\n",
       "      <td>-1.058</td>\n",
       "      <td>-0.757</td>\n",
       "      <td>7.666613e+09</td>\n",
       "      <td>5.546273e+08</td>\n",
       "      <td>97230120.0</td>\n",
       "      <td>...</td>\n",
       "      <td>1.487741e+08</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.165037e+07</td>\n",
       "      <td>-1.06</td>\n",
       "      <td>-0.0871</td>\n",
       "      <td>5b3edcd250d2c15048799289</td>\n",
       "      <td>600100</td>\n",
       "      <td>2018-03-31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 285 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       EPS  deductEPS  undistributedProfitPerShare  \\\n",
       "report_date code                                                     \n",
       "2017-03-31  000001  0.3100     0.3100                         4.05   \n",
       "2017-06-30  000001  0.6800     0.6800                         4.26   \n",
       "2017-12-31  000001  1.3000     1.3000                         4.64   \n",
       "2018-03-31  000001  0.3300     0.3300                         4.69   \n",
       "2017-03-31  600100 -0.0908    -0.1030                         2.57   \n",
       "2017-06-30  600100 -0.0407    -0.0598                         2.37   \n",
       "2017-12-31  600100  0.0350    -0.0115                         2.45   \n",
       "2018-03-31  600100 -0.0756    -0.0871                         2.37   \n",
       "\n",
       "                    netAssetsPerShare  capitalReservePerShare     ROE  \\\n",
       "report_date code                                                        \n",
       "2017-03-31  000001            10.9400                    3.29   2.992   \n",
       "2017-06-30  000001            11.1500                    3.29   6.100   \n",
       "2017-12-31  000001            11.7706                    3.29  11.474   \n",
       "2018-03-31  000001            11.8500                    3.29   3.242   \n",
       "2017-03-31  600100             7.1879                    3.15  -1.263   \n",
       "2017-06-30  600100             6.9775                    3.15  -0.584   \n",
       "2017-12-31  600100             7.1765                    3.10   0.487   \n",
       "2018-03-31  600100             7.1433                    3.20  -1.058   \n",
       "\n",
       "                    operatingCashFlowPerShare    moneyFunds  \\\n",
       "report_date code                                              \n",
       "2017-03-31  000001                     -6.700  7.121477e+11   \n",
       "2017-06-30  000001                     -7.470  7.522773e+11   \n",
       "2017-12-31  000001                     -6.920  7.506320e+11   \n",
       "2018-03-31  000001                      2.410  6.699981e+11   \n",
       "2017-03-31  600100                     -0.885  7.738101e+09   \n",
       "2017-06-30  600100                     -1.124  8.756578e+09   \n",
       "2017-12-31  600100                      0.153  9.766134e+09   \n",
       "2018-03-31  600100                     -0.757  7.666613e+09   \n",
       "\n",
       "                    tradingFinancialAssets  billsReceivables     ...       \\\n",
       "report_date code                                                 ...        \n",
       "2017-03-31  000001            4.404400e+10               NaN     ...        \n",
       "2017-06-30  000001            4.908300e+10               NaN     ...        \n",
       "2017-12-31  000001            3.957500e+10               NaN     ...        \n",
       "2018-03-31  000001            7.684500e+10               NaN     ...        \n",
       "2017-03-31  600100            9.173491e+08        90043088.0     ...        \n",
       "2017-06-30  600100            7.745308e+08        52524456.0     ...        \n",
       "2017-12-31  600100            5.818680e+08       117617800.0     ...        \n",
       "2018-03-31  600100            5.546273e+08        97230120.0     ...        \n",
       "\n",
       "                    netProfitLastYear  277  278  279           280    281  \\\n",
       "report_date code                                                            \n",
       "2017-03-31  000001       2.272700e+10  NaN  NaN  2.0  6.955837e+08   2.89   \n",
       "2017-06-30  000001       2.286100e+10  NaN  NaN  2.0  7.684470e+08   6.21   \n",
       "2017-12-31  000001       2.318900e+10  NaN  NaN  3.0  1.071157e+09  11.62   \n",
       "2018-03-31  000001       2.357000e+10  NaN  NaN  3.0  9.828775e+08   2.79   \n",
       "2017-03-31  600100      -1.169131e+09  NaN  NaN  3.0  4.155126e+07  -1.25   \n",
       "2017-06-30  600100      -7.752181e+08  NaN  NaN  3.0  4.842445e+07  -0.56   \n",
       "2017-12-31  600100       1.036393e+08  NaN  NaN  4.0  5.628596e+07   0.48   \n",
       "2018-03-31  600100       1.487741e+08  NaN  NaN  2.0  4.165037e+07  -1.06   \n",
       "\n",
       "                       282                       _id    code  report_date  \n",
       "report_date code                                                           \n",
       "2017-03-31  000001  0.3617  5b3edccc50d2c15048795415  000001   2017-03-31  \n",
       "2017-06-30  000001  0.3670  5b3edcce50d2c15048796114  000001   2017-06-30  \n",
       "2017-12-31  000001  0.2348  5b3edcd150d2c15048797c47  000001   2017-12-31  \n",
       "2018-03-31  000001  0.3818  5b3edcd250d2c15048798a07  000001   2018-03-31  \n",
       "2017-03-31  600100 -0.1030  5b3edccc50d2c15048795c3a  600100   2017-03-31  \n",
       "2017-06-30  600100  0.0432  5b3edcce50d2c15048796987  600100   2017-06-30  \n",
       "2017-12-31  600100  0.0791  5b3edcd150d2c150487984ca  600100   2017-12-31  \n",
       "2018-03-31  600100 -0.0871  5b3edcd250d2c15048799289  600100   2018-03-31  \n",
       "\n",
       "[8 rows x 285 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "res_adv=QA.QA_fetch_financial_report_adv('000001','2017-01-01','2018-05-01')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "< QA_DataStruct_Financial >"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res_adv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>EPS</th>\n",
       "      <th>deductEPS</th>\n",
       "      <th>undistributedProfitPerShare</th>\n",
       "      <th>netAssetsPerShare</th>\n",
       "      <th>capitalReservePerShare</th>\n",
       "      <th>ROE</th>\n",
       "      <th>operatingCashFlowPerShare</th>\n",
       "      <th>moneyFunds</th>\n",
       "      <th>tradingFinancialAssets</th>\n",
       "      <th>billsReceivables</th>\n",
       "      <th>...</th>\n",
       "      <th>netProfitLastYear</th>\n",
       "      <th>277</th>\n",
       "      <th>278</th>\n",
       "      <th>279</th>\n",
       "      <th>280</th>\n",
       "      <th>281</th>\n",
       "      <th>282</th>\n",
       "      <th>_id</th>\n",
       "      <th>code</th>\n",
       "      <th>report_date</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>report_date</th>\n",
       "      <th>code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-03-31</th>\n",
       "      <th>000001</th>\n",
       "      <td>0.31</td>\n",
       "      <td>0.31</td>\n",
       "      <td>4.05</td>\n",
       "      <td>10.9400</td>\n",
       "      <td>3.29</td>\n",
       "      <td>2.992</td>\n",
       "      <td>-6.70</td>\n",
       "      <td>7.121477e+11</td>\n",
       "      <td>4.404400e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.272700e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>6.955837e+08</td>\n",
       "      <td>2.89</td>\n",
       "      <td>0.3617</td>\n",
       "      <td>5b3edccc50d2c15048795415</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-03-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-06-30</th>\n",
       "      <th>000001</th>\n",
       "      <td>0.68</td>\n",
       "      <td>0.68</td>\n",
       "      <td>4.26</td>\n",
       "      <td>11.1500</td>\n",
       "      <td>3.29</td>\n",
       "      <td>6.100</td>\n",
       "      <td>-7.47</td>\n",
       "      <td>7.522773e+11</td>\n",
       "      <td>4.908300e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.286100e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.684470e+08</td>\n",
       "      <td>6.21</td>\n",
       "      <td>0.3670</td>\n",
       "      <td>5b3edcce50d2c15048796114</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-06-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-09-30</th>\n",
       "      <th>000001</th>\n",
       "      <td>1.06</td>\n",
       "      <td>1.06</td>\n",
       "      <td>4.64</td>\n",
       "      <td>11.5400</td>\n",
       "      <td>3.29</td>\n",
       "      <td>8.782</td>\n",
       "      <td>-9.20</td>\n",
       "      <td>7.265024e+11</td>\n",
       "      <td>4.132700e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.303300e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>8.339691e+08</td>\n",
       "      <td>9.60</td>\n",
       "      <td>0.3854</td>\n",
       "      <td>5b3edccf50d2c15048796eaa</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-09-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31</th>\n",
       "      <th>000001</th>\n",
       "      <td>1.30</td>\n",
       "      <td>1.30</td>\n",
       "      <td>4.64</td>\n",
       "      <td>11.7706</td>\n",
       "      <td>3.29</td>\n",
       "      <td>11.474</td>\n",
       "      <td>-6.92</td>\n",
       "      <td>7.506320e+11</td>\n",
       "      <td>3.957500e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.318900e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.071157e+09</td>\n",
       "      <td>11.62</td>\n",
       "      <td>0.2348</td>\n",
       "      <td>5b3edcd150d2c15048797c47</td>\n",
       "      <td>000001</td>\n",
       "      <td>2017-12-31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-03-31</th>\n",
       "      <th>000001</th>\n",
       "      <td>0.33</td>\n",
       "      <td>0.33</td>\n",
       "      <td>4.69</td>\n",
       "      <td>11.8500</td>\n",
       "      <td>3.29</td>\n",
       "      <td>3.242</td>\n",
       "      <td>2.41</td>\n",
       "      <td>6.699981e+11</td>\n",
       "      <td>7.684500e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2.357000e+10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.0</td>\n",
       "      <td>9.828775e+08</td>\n",
       "      <td>2.79</td>\n",
       "      <td>0.3818</td>\n",
       "      <td>5b3edcd250d2c15048798a07</td>\n",
       "      <td>000001</td>\n",
       "      <td>2018-03-31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 285 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     EPS  deductEPS  undistributedProfitPerShare  \\\n",
       "report_date code                                                   \n",
       "2017-03-31  000001  0.31       0.31                         4.05   \n",
       "2017-06-30  000001  0.68       0.68                         4.26   \n",
       "2017-09-30  000001  1.06       1.06                         4.64   \n",
       "2017-12-31  000001  1.30       1.30                         4.64   \n",
       "2018-03-31  000001  0.33       0.33                         4.69   \n",
       "\n",
       "                    netAssetsPerShare  capitalReservePerShare     ROE  \\\n",
       "report_date code                                                        \n",
       "2017-03-31  000001            10.9400                    3.29   2.992   \n",
       "2017-06-30  000001            11.1500                    3.29   6.100   \n",
       "2017-09-30  000001            11.5400                    3.29   8.782   \n",
       "2017-12-31  000001            11.7706                    3.29  11.474   \n",
       "2018-03-31  000001            11.8500                    3.29   3.242   \n",
       "\n",
       "                    operatingCashFlowPerShare    moneyFunds  \\\n",
       "report_date code                                              \n",
       "2017-03-31  000001                      -6.70  7.121477e+11   \n",
       "2017-06-30  000001                      -7.47  7.522773e+11   \n",
       "2017-09-30  000001                      -9.20  7.265024e+11   \n",
       "2017-12-31  000001                      -6.92  7.506320e+11   \n",
       "2018-03-31  000001                       2.41  6.699981e+11   \n",
       "\n",
       "                    tradingFinancialAssets  billsReceivables     ...       \\\n",
       "report_date code                                                 ...        \n",
       "2017-03-31  000001            4.404400e+10               NaN     ...        \n",
       "2017-06-30  000001            4.908300e+10               NaN     ...        \n",
       "2017-09-30  000001            4.132700e+10               NaN     ...        \n",
       "2017-12-31  000001            3.957500e+10               NaN     ...        \n",
       "2018-03-31  000001            7.684500e+10               NaN     ...        \n",
       "\n",
       "                    netProfitLastYear  277  278  279           280    281  \\\n",
       "report_date code                                                            \n",
       "2017-03-31  000001       2.272700e+10  NaN  NaN  2.0  6.955837e+08   2.89   \n",
       "2017-06-30  000001       2.286100e+10  NaN  NaN  2.0  7.684470e+08   6.21   \n",
       "2017-09-30  000001       2.303300e+10  NaN  NaN  3.0  8.339691e+08   9.60   \n",
       "2017-12-31  000001       2.318900e+10  NaN  NaN  3.0  1.071157e+09  11.62   \n",
       "2018-03-31  000001       2.357000e+10  NaN  NaN  3.0  9.828775e+08   2.79   \n",
       "\n",
       "                       282                       _id    code  report_date  \n",
       "report_date code                                                           \n",
       "2017-03-31  000001  0.3617  5b3edccc50d2c15048795415  000001   2017-03-31  \n",
       "2017-06-30  000001  0.3670  5b3edcce50d2c15048796114  000001   2017-06-30  \n",
       "2017-09-30  000001  0.3854  5b3edccf50d2c15048796eaa  000001   2017-09-30  \n",
       "2017-12-31  000001  0.2348  5b3edcd150d2c15048797c47  000001   2017-12-31  \n",
       "2018-03-31  000001  0.3818  5b3edcd250d2c15048798a07  000001   2018-03-31  \n",
       "\n",
       "[5 rows x 285 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res_adv.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "fds=QA.QA_DataStruct_Financial(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "< QA_DataStruct_Financial >"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1.2630000114"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fds.get_key('600100','2017-03-31','ROE')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "EPS                                                            -0.0908\n",
       "deductEPS                                                       -0.103\n",
       "undistributedProfitPerShare                                       2.57\n",
       "netAssetsPerShare                                               7.1879\n",
       "capitalReservePerShare                                            3.15\n",
       "ROE                                                             -1.263\n",
       "operatingCashFlowPerShare                                       -0.885\n",
       "moneyFunds                                                  7.7381e+09\n",
       "tradingFinancialAssets                                     9.17349e+08\n",
       "billsReceivables                                           9.00431e+07\n",
       "accountsReceivables                                        7.19131e+09\n",
       "prepayments                                                1.51541e+09\n",
       "otherReceivables                                           9.41644e+08\n",
       "interCompanyReceivables                                            NaN\n",
       "interestReceivables                                                  0\n",
       "dividendsReceivables                                       1.68134e+07\n",
       "inventory                                                  9.57452e+09\n",
       "expendableBiologicalAssets                                         NaN\n",
       "noncurrentAssetsDueWithinOneYear                                     0\n",
       "otherLiquidAssets                                          3.17298e+09\n",
       "totalLiquidAssets                                          3.11582e+10\n",
       "availableForSaleSecurities                                 2.92698e+09\n",
       "heldToMaturityInvestments                                            0\n",
       "longTermReceivables                                        8.95877e+08\n",
       "longTermEquityInvestment                                   1.33009e+10\n",
       "investmentRealEstate                                       1.45896e+07\n",
       "fixedAssets                                                3.26195e+09\n",
       "constructionInProgress                                     6.67087e+08\n",
       "engineerMaterial                                                     0\n",
       "fixedAssetsCleanUp                                                   0\n",
       "                                                        ...           \n",
       "socialSecurityNumber                                               NaN\n",
       "socialSecurityShareholding                                         NaN\n",
       "privateEquityNumber                                                  1\n",
       "privateEquityShareholding                                  8.00007e+06\n",
       "financialCompanyNumber                                             NaN\n",
       "financialCompanyShareholding                                       NaN\n",
       "pensionInsuranceAgencyNumber                                       NaN\n",
       "pensionInsuranceAgencyShareholfing                                 NaN\n",
       "totalNumberOfTopTenCirculationShareholders                 5.85248e+08\n",
       "firstLargeCirculationShareholdersNumber                    4.73639e+08\n",
       "freeCirculationStock                                       1.72424e+09\n",
       "limitedCirculationAShares                                  7.66017e+08\n",
       "generalRiskPreparation                                             NaN\n",
       "otherComprehensiveIncome                                  -2.10654e+08\n",
       "totalComprehensiveIncome                                  -5.05396e+08\n",
       "shareholdersOwnershipOfAParentCompany                      2.13041e+10\n",
       "bankInstutionNumber                                                NaN\n",
       "bankInstutionShareholding                                          NaN\n",
       "corporationNumber                                                    1\n",
       "corporationShareholding                                    4.73639e+08\n",
       "netProfitLastYear                                         -1.16913e+09\n",
       "277                                                                NaN\n",
       "278                                                                NaN\n",
       "279                                                                  3\n",
       "280                                                        4.15513e+07\n",
       "281                                                              -1.25\n",
       "282                                                             -0.103\n",
       "_id                                           5b3edccc50d2c15048795c3a\n",
       "code                                                            600100\n",
       "report_date                                        2017-03-31 00:00:00\n",
       "Name: (2017-03-31 00:00:00, 600100), Length: 285, dtype: object"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fds.get_report_by_date('600100','2017-03-31')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
